package com.ms.service.module.datacenterlite;

import com.xpec.c4.message.MessageTypes;
import com.xpec.c4.service.group.transportlayer.GroupMessage;
import com.xpec.c4.service.message.MessageAction;

public class TransactionProcessor {
	
	/**
	 * 處理兩個地方以上修改同個資料的問題，防止競賽
	 */
	public static void OnCentralAsyncExecute(CentralAsyncCommand request, DataCenterLiteModule module){
		
		CentralDataAsync executeData = new CentralDataAsync();
		executeData.command = request;
		executeData.setQueueID(request.getQueueID());
		module.addAsyncCommand(executeData);
	}
	
	public static void callbackCenter(CentralAsyncCommand obj, String moduleID){
		
		GroupMessage msg = new GroupMessage();
		msg.setMessageType(MessageTypes.S_CENTRAL_RESPONSE);
		msg.setMessageContent(obj);
		msg.setDestModuleID(moduleID);
		MessageAction.sendMessage(msg);
	}
	
	
}
